<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if(sizeof($items) > 0){
	echo "<div class='jqf_w100_div'>";
		echo $sort_form;
		echo $sort_js;
	echo "</div>";
}

	if ($catalog_active_category['parent_title'] != "") {
		echo "<h1>".$catalog_active_category['parent_title']."</h1>";
	}

	if (sizeof($pages) > 0) {
		echo "<div>";
		foreach ($pages as $page) {
			echo "<div class='catalog-category-item'>";
				echo "<div class='image'>";
				$parent_link = "/catalog/category/".$page['parent_id']."/";
					echo "<a href='".$parent_link."'>";
						if ($page['parent_image'] != "" && file_exists("./uploads/catalog_parents/".$page['parent_id']."/middle/".$page['parent_image'])) {
							$im = getimagesize("./uploads/catalog_parents/".$page['parent_id']."/middle/".$page['parent_image']);
							$margin = round((200 - $im[1]) / 2);
							echo "<img src='/uploads/catalog_parents/".$page['parent_id']."/middle/".$page['parent_image']."' alt='".$page['parent_title']."' title='".$page['parent_title']."' style='margin: ".$margin."px auto 0 auto;' />";
						} else {
							echo "<img src='/data/images/x.gif' alt='".$page['parent_title']."' title='".$page['parent_title']."' />";
						}
					echo "</a>";
				echo "</div>";
				echo "<div class='name'>";
					echo "<a href='".$parent_link."'>".$page['parent_title'];
					echo " (".$this->db->select()->from('catalog_items')->where('item_parent',$page['parent_id'])->count_all_results().")";
					echo "</a>";
				echo "</div>";
			echo "</div>";
		}
		echo "</div>";
		echo "<br class='cc'/>";
	}
	if (sizeof($items) > 0) {
		echo "<div class='catalog-parent-items'>";
		echo "<div class='spike-top'></div>";
		echo "<div class='spike-bottom'></div>";
		echo "<div class='spike-left'></div>";
		echo "<div class='spike-right'></div>";
		foreach ($items as $item) {
			$data['item'] = $item;
			$this->load->view('modules/catalog/one_item', $data);
		}
		echo "<br class='cc'/>";
		echo "</div>";
		if ($paging) echo $paging;
	}

	if (sizeof($pages) <= 0 && sizeof($items) <= 0) {
		echo showmenotice('По выбранным параметрам нет товаров, попробуйте изменить свой запрос');
	}
	if (sizeof($pages) > 0) {
		$slider = $this->slider_model->all($id,'hit');
		if(mb_strlen($slider) > 0){
			echo '<h2 class="slider_h2">Лидеры продаж</h2>';
			echo '<div class="big_center_slider">';
			echo $slider;
			echo '</div>';
		}
	}
?>